const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin');

const extractSass = new ExtractTextPlugin({
    filename: "[name].[hash].css",
    disable: process.env.NODE_ENV === "development"
});

module.exports = {
	entry: './vuejs/app.js',
	output: {
		filename: 'app.js',
		path: path.resolve(__dirname, './public/static'),
		publicPath: '/static/'
	},
	module: {
		rules: [
			{
				test: /\.scss$/,
				use: extractSass.extract({
                use: [{
	                    loader: "css-loader"
	                }, {
	                    loader: "sass-loader"
	                }],
	                fallback: "style-loader"
	            })
			},
			{
				test: /\.vue$/,
				use: 'vue-loader'
			},
			{
		         test: /\.css$/,
		         use: [
		           'style-loader',
		           'css-loader'
		         ]
		    },
		    {
		    	test: /\.(woff|woff2|eot|ttf|otf)$/,
		    	use: [
		    		"file-loader"
		    	]
		    },
		    {
	          test: /\.(png|svg|jpg|gif)$/,
	          use: [
	            'file-loader'
	          ]
	        },
		]
	},
	plugins: [
		new CleanWebpackPlugin(['dist']),
		extractSass,
		new VueLoaderPlugin()
	],
	resolve: {
	    alias: {
	      'vue$': 'vue/dist/vue.esm.js'
	    }
	}
}